// MyEditor.h
// Simple text editor.

#ifndef MYEDITOR_H
#define MYEDITOR_H

#include <QMainWindow>

// Class declaration without loading .h files. Faster compilation.
class QAction;
class QMenu;
class QPlainTextEdit;

class MyEditor: public QMainWindow
{
    Q_OBJECT

public:
    MyEditor();

protected:
    void closeEvent(QCloseEvent *event);

private slots:
    void open();
    bool save();
    void about();
    void isModified();

private:
    void createWidgets();
    void createActions();
    void createMenus();
    void createToolBars();
    void createStatusBar();

    QAction *openAction;
    QAction *saveAction;
    QAction *exitAction;
    QAction *cutAction;
    QAction *pasteAction;
    QAction *aboutAction;

    QMenu *fileMenu;
    QMenu *editMenu;
    QMenu *helpMenu;
    
    QToolBar *fileToolBar;
    QToolBar *editToolBar;
    
    // Widgets and variables
    QPlainTextEdit *textEdit;
    QString currFile;

    // Supporting methods
    bool okToContinue();
    void loadFile(const QString &fileName);
    bool saveFile(const QString &fileName);
    void setCurrentFile(const QString &fileName);
};

#endif
